<!--
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * date: 2021-12-01 09:56:57
 * @LastEditors: Sam
 * @LastEditTime: 2021-12-08 20:20:55
-->
{include file="common/public/header"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card">
            <div class="layui-card-header">搜索</div>
            <div class="layui-card-body">
                {$where|raw}
            </div>
        </div>
        
    </div>
</div>
<div class="layui-fluid">
  
    <div class="layui-row layui-col-space15">
        <div class="layui-card">
          <div class="layui-card-header">{$page_title}</div>
            <div class="layui-card-body">
                
                <table id="table"></table>
                <script type="text/html" id="pid">
                    <a href="{:Url('index')}?pid={{d.id}}">查看</a>
                </script>
                <script type="text/html" id="is_show">
                    <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show'  lay-text='显|隐'  {{ d.is_show == 1 ? 'checked' : '' }}>
                </script>
                <script type="text/html" id="pic">
                    {{# if(d.pic){ }}
                    <img style="cursor: pointer" lay-event='open_image' src="{{d.pic}}">
                    {{# }else{ }}
                    暂无图片
                    {{# } }}
                </script>
                <script type="text/html" id="toolbarDemo">
                    <div class="layui-btn-container">
                        {:access_button('admin/StoreCategory/index',[],'分类首页')}
                        {:access_button('admin/StoreCategory/add',[],'添加分类','frame',['850px','680px'])}
                    </div>
                  </script>
                <script type="text/html" id="act">
                    {:table_button('admin/StoreCategory/edit', '编辑','frame','',['850px','680px'])}
                    {:table_button('admin/StoreCategory/del', '删除','confirm','',['850px','680px'])}
                </script>

            </div>
        </div>

    </div>
</div>
{include file="common/public/footer" /}
{include file="common/public/table" /}
<script>
    layui.use(['index', 'form', 'table'], function(){
        var $       = layui.$;
        var table   = layui.table;
        var  form   = layui.form;
        table.render({
        elem: '#table'
        ,url: " " //数据接口
        ,page: true //开启分页
        ,method:'POST'
        ,defaultToolbar: []
        ,cols: [[ //表头
            {field: 'id', title: 'ID',event:'id',align:'center'},
            {field: 'pid_name', title: '父级',align:'center'},
            {field: 'cate_name', title: '分类名称',align:'center'},
            {field: 'pid', title: '查看子分类',templet:'#pid',align:'center'},
            {field: 'pic', title: '分类图标',templet:'#pic',align:'center'},
            {field: 'sort', title: '排序',event:'sort',edit:'sort',align:'center'},
            {field: 'is_show', title: '状态',templet:'#is_show',align:'center'},
            {field: 'right', title: '操作',align:'center',toolbar:'#act',align:'center'},
        ]]
        ,toolbar: '#toolbarDemo'
    });
    form.on('switch(is_show)', function(data) {
            var url = "{:url('admin/StoreCategory/is_show')}";
            Post(url, {checked: $(data.elem).is(":checked") ? 1: 0,id:data.value}, function(res) {
                if(res.code == 1) {
                    table_reload();
                }else {
                    alert_error(res.msg);
                }
            });
        });
});
</script>